package com.room2;

import android.content.Context;

import com.room2.model.Score;
import com.room2.model.ScoreDao;
import com.room2.model.User;
import com.room2.model.UserDao;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

@Database(entities = {Score.class, User.class}, version = 1, exportSchema = false)
public abstract class AppDatabase extends RoomDatabase {
    private static AppDatabase INSTANCE;

    public abstract ScoreDao getScoreDao();

    public abstract UserDao getUserDao();

    public static synchronized AppDatabase getInstance(Context context) {
        if (INSTANCE == null) {
            INSTANCE = Room.databaseBuilder(
                    context,
                    AppDatabase.class,
                    "room-data"
            ).allowMainThreadQueries().build();
        }
        return INSTANCE;
    }


}
